home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The X-Philes (2nd Revision)
/
The X-Philes Number 1 (1995).iso
/
xphiles
/
hp48hor2
/
expand.doc
< prev
next >
Wrap
Text File
|
1995-03-31
|
2KB
|
38 lines
EXPAND.DOC by Joe Horn
All about the System RPL word 'EXPAND'
EXPAND appends zeros onto a character string or hex string.
The 'MKHXS' program on Goodies Disk #7 uses EXPAND. Its DOC file
stated that it is unfortunate that HP's documentation fails to explain
the EXPAND command. So, here's the explanation.
INPUT:
2: String (either $ or HXS)
1: System Binary (number of zeros you want to append to string)
OUTPUT:
1: null-expanded String (padded with trailing nulls, on right end)
NB: The System Binary refers to the number of zero NIBBLES you wish to
append; if you expand a string, use a number TWICE as large as the
number of null bytes you wish to append.
EXAMPLES: "ABC" # 8h EXPAND --> "ABC...." (4 nulls appended)
"ABC" # Ah EXPAND --> "ABC....." (5 nulls appended)
NULLHXS # 8h EXPAND --> HXS 8 00000000
HXS 3 123 # 4 EXPAND --> HXS 1230000
IMPORTANT: Using EXPAND on character strings with an odd number in
stack level one creates character strings with odd nibble
lengths, which is not a normal situation. The trailing "extra" nibble
will be invisible in the display, but is not lost during any normal
string operations. Although this cannot cause any problems such as
corrupting memory, it can lead to unexpected results, such as two
strings that look identical not comparing as equal; or concatenating
strings and "nibble-shifting" the second one into garbage. You can
also hide a value in this hidden nibble. Just be careful that you
don't forget its presence.